package ingsw2.ii.dp.reader;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;

public class MyFilePrinter extends MyStatistic implements MyPrint {

	private ArrayList<BufferedWriter> myArray = new ArrayList<BufferedWriter>();
	private int num;

	public MyFilePrinter(String ... filenames) throws IOException{
		if (filenames.length<0)
			throw new IOException("No file!");
		num = filenames.length;
		for (int i=0; i<this.num ; i++){
			myArray.add(new BufferedWriter(new FileWriter(filenames[i]))); 
		}
	}

	@Override
	public void write(String value) {
		try {
			for (int i=0; i<this.num; i++){
				myArray.get(i).write(value+"\n");
				myArray.get(i).flush();
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}
